package operation;
import book.BookList;

import book.Book;

import java.util.Scanner;

/**
 * Created with Intellij IDEA.
 * Description:
 * User: wangj
 * Date: 2022-02-28
 * Time: 23:41
 */
public class AddOperation implements IOperation{
    public void work(BookList bookList) {
        System.out.println("增加图书！");
        Scanner scn=new Scanner(System.in);
        System.out.println("请输入新增图书的名字:");
        String name= scn.nextLine();
        System.out.println("请输入新增图书的作者:");
        String author= scn.nextLine();
        System.out.println("请输入新增图书的类型:");
        String type= scn.nextLine();
        System.out.println("请输入新增图书的价格:");
        int price= scn.nextInt();
        Book book=new Book(name,author,price,type);
        int currentSize= bookList.getUsedSize();
        bookList.setBookList(book,currentSize);
        bookList.setUsedSize(currentSize+1);//成功放入一本书
        System.out.println("新增成功！");
    }
}
